﻿using CommunityToolkitMvvmDemo.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;
using System.Windows;

namespace CommunityToolkitMvvmDemo.Selectors
{
    public class ListBoxItemTemplateSelector : DataTemplateSelector
    {
        public DataTemplate NormalTemplate { get; set; }
        public DataTemplate AlarmTemplate { get; set; }

        public override DataTemplate SelectTemplate(object item, DependencyObject container)
        {
            var person = item as Person;
            if (person.Age > 100)
            {
                return AlarmTemplate;
            }
            return NormalTemplate;
        }
    }
}
